
a=-748;b=700;r1=892;r2=1280;
r1=r1+20;
r2=r2-20;
a_inner = a;   
a_outer = a;
b_inner = b;
b_outer = b;

% str_read = 'F:\点火PIV实验\处理结果\冷态8-286不同高度\60mm.bmp';
str_read = 'F:\毕业设计\毕设结题\pics更新\4.3_8-286_冷态不同高度\50mm.bmp';
rgb=imread(str_read);   

[m,n,k]=size(rgb); %rgb 例：图像的尺寸m * n * k  == 612 * 1537 * 3  uint8

%把裁掉边框的部分放在rgb1中
PIV_a = m-37;
PIV_b = n-25;
A=zeros(PIV_a,PIV_b);
A=uint8(A);
rgb1=cat(3,A,A,A);
for i=1:PIV_a
    for j=1:PIV_b
        rgb1(i,j,:)=rgb(i+16,j+11,:);%裁掉边框的部分
    end
end

row = 552;col = 1392;   %默认以高通图片尺寸为全局
rgb1= imresize(rgb1,[row col]);

%% 两侧
 %rgb1 边界涂白，消除之前的处理痕迹
check = 1;
for i=1:row
    for j=1:col  
        check= (i-a_inner).^2+(j-b_inner).^2-r1^2;
        if check<0
            rgb1(i,j,1)=255;
            rgb1(i,j,2)=255;
            rgb1(i,j,3)=255;
        end
        check= (i-a_outer).^2+(j-b_outer).^2-r2^2;
        if check>0
            rgb1(i,j,1)=255;
            rgb1(i,j,2)=255;
            rgb1(i,j,3)=255;
        end
    end
end
%% 边框
%rgb1 内外壁涂黑
r1_new=r1;
r2_new=r2;
a1=zeros(row,col);
for i=1:row
    for j=1:col
        a1(i,j)= (i-a_inner).^2+(j-b_inner).^2-r1_new^2;
        if (a1(i,j)<1500) && (a1(i,j)>-1500) %649 * 5pixels
            rgb1(i,j,1)=0;
            rgb1(i,j,2)=0;
            rgb1(i,j,3)=0;
        end
        a1(i,j)= (i-a_outer).^2+(j-b_outer).^2-r2_new^2;
        if ( a1(i,j)<2000) && ( a1(i,j)>-2000 )
            rgb1(i,j,1)=0;
            rgb1(i,j,2)=0;
            rgb1(i,j,3)=0;
        end
    end
end

%rgb1 上方的涂黑
for i=1:2
    for j=1:col %214 174
        a1(i,j)= (i-a_inner).^2+(j-b_inner).^2-r1^2;
        if a1(i,j)>=0
            rgb1(i,j,1)=0;
            rgb1(i,j,2)=0;
            rgb1(i,j,3)=0;
        end
    end
end
%rgb1 左右两边的涂黑
for i=1:row %284  310
    for j=1:2
        check1 = (i-a_outer).^2+(j-b_outer).^2-r2^2;
        check2 = (i-a_inner).^2+(j-b_inner).^2-r1^2;
        if check1 <= 0 && check2>=0
            rgb1(i,j,1)=0;
            rgb1(i,j,2)=0;
            rgb1(i,j,3)=0;
        end

    end
end

for i=1:row %284  310
    for j=col-1:col
        check1 = (i-a_outer).^2+(j-b_outer).^2-r2^2;
        check2 = (i-a_inner).^2+(j-b_inner).^2-r1^2;
        if check1 <= 0 && check2>=0
            rgb1(i,j,1)=0;
            rgb1(i,j,2)=0;
            rgb1(i,j,3)=0;
        end

    end
end

% imshow(rgb1);
imwrite(rgb1,str_read)
    
    
    
    
    
    
    
    
    
    
    
    %imwrite(rgb1,['C:\Users\QCH\Desktop\' '1.tif']);

    
%     if current_bmp<10
%          str_bmp = strcat (str_read,'PIVlab_out_','00',int2str(current_bmp) , '.bmp'); % 连接字符串形成图像的文件名
%     elseif current_bmp<100
%          str_bmp = strcat (str_read,'PIVlab_out_','0',int2str(current_bmp) , '.bmp');
%     elseif current_bmp<1000
%          str_bmp = strcat (str_read, 'PIVlab_out_',int2str(current_bmp), '.bmp');
%     else
%         fprintf('CHECK1!! the SUM and serial number of Files does not match to this programme.');
%     end
%     
%     
%     rgb=imread(str_bmp);    %rms图
%     
%     [m,n,k]=size(rgb); %rgb 例：图像的尺寸m * n * k  == 612 * 1537 * 3  uint8
%     
%     %把裁掉边框的部分放在rgb1中
%     PIV_a = m-25;
%     PIV_b = n-28;
%     A=zeros(PIV_a,PIV_b);
%     A=uint8(A);
%     rgb1=cat(3,A,A,A);
%     for i=1:PIV_a
%         for j=1:PIV_b
%             rgb1(i,j,:)=rgb(i+12,j+12,:);%裁掉边框的部分
%         end
%     end
%     
%     %设定全局尺寸 待修改
%     row1=row;col1=col;   %默认以高通图片尺寸为全局
%     rgb1= imresize(rgb1,[row col]);
%     %imwrite(rgb1,['C:\Users\QCH\Desktop\' '1.tif']);